package com.bijava.controller;

import com.bijava.utils.LoggerFactoryUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author bijava
 * @version 1.0
 * @since 20-9-8
 */
@RestController
public class Log4j2Controller {
    private static final Logger LOGGER = LoggerFactory.getLogger(Log4j2Controller.class);
    /**
     * 日志级别
     * OFF > FATAL > ERROR > WARN > INFO > DEBUG > TRACE > ALL
     */
    @GetMapping("/printLog1")
    public String printLog1 (){
        LOGGER.error("ERROR 级别日志");
        LOGGER.warn("WARN 级别日志");
        LOGGER.info("INFO 级别日志");
        LOGGER.debug("DEBUG 级别日志");
        LOGGER.trace("TRACE 级别日志");
        return "success";
    }

    private static final Logger log = LoggerFactoryUtil.get();
    @GetMapping("/printLog2")
    public String printLog2 (){
        LoggerFactoryUtil.error(log,"ERROR 级别日志");
        LoggerFactoryUtil.warn(log,"WARN 级别日志");
        LoggerFactoryUtil.info(log,"INFO 级别日志");
        LoggerFactoryUtil.debug(log,"DEBUG 级别日志");
        LoggerFactoryUtil.trace(log,"TRACE 级别日志");
        return "success";
    }
}